﻿namespace dk.Helper.Base
{
    public class Interval
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Interval"/> class.
        /// </summary>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        public Interval(int start, int end)
        {
            Start = start;
            End = end;
        }

        /// <summary>
        /// Gets or sets the start.
        /// </summary>
        /// <value>
        /// The start.
        /// </value>
        public int Start { get; set; }

        /// <summary>
        /// Gets or sets the end.
        /// </summary>
        /// <value>
        /// The end.
        /// </value>
        public int End { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether this instance is defined.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is defined; otherwise, <c>false</c>.
        /// </value>
        public bool IsDefined { get; set; }

        /// <summary>
        /// Ins the range.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public bool InRange(int value)
        {
            if (!IsDefined) return false;
            return ((Start <= value) && value <= End);
        }
    }
}